package com.qulai.web.controller.ql;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.qulai.common.annotation.Log;
import com.qulai.common.core.controller.BaseController;
import com.qulai.common.core.domain.AjaxResult;
import com.qulai.common.enums.BusinessType;
import com.qulai.amazon_us.domain.ql.QlShop;
import com.qulai.amazon_us.service.ql.IQlShopService;
import com.qulai.common.utils.poi.ExcelUtil;
import com.qulai.common.core.page.TableDataInfo;


/**
 * 去来店铺Controller
 * 
 * @author hunan
 * @date 2025-07-17
 */
@RestController
@RequestMapping("/ql/shop")
public class QlShopController extends BaseController
{
    @Autowired
    private IQlShopService qlShopService;

    /**
     * 查询去来店铺列表
     */
    @PreAuthorize("@ss.hasPermi('ql:shop:list')")
    @GetMapping("/list")
    public TableDataInfo list(QlShop qlShop)
    {
        startPage();
        List<QlShop> list = qlShopService.selectQlShopList(qlShop);
        return getDataTable(list);
    }

    /**
     * 导出去来店铺列表
     */
    @PreAuthorize("@ss.hasPermi('ql:shop:export')")
    @Log(title = "去来店铺", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, QlShop qlShop)
    {
        List<QlShop> list = qlShopService.selectQlShopList(qlShop);
        ExcelUtil<QlShop> util = new ExcelUtil<QlShop>(QlShop.class);
        util.exportExcel(response, list, "去来店铺数据");
    }

    /**
     * 获取去来店铺详细信息
     */
    @PreAuthorize("@ss.hasPermi('ql:shop:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return success(qlShopService.selectQlShopById(id));
    }

    /**
     * 新增去来店铺
     */
    @PreAuthorize("@ss.hasPermi('ql:shop:add')")
    @Log(title = "去来店铺", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody QlShop qlShop)
    {
        qlShop.setUpdateBy(getUsername());
        return toAjax(qlShopService.insertQlShop(qlShop));
    }

    /**
     * 修改去来店铺
     */
    @PreAuthorize("@ss.hasPermi('ql:shop:edit')")
    @Log(title = "去来店铺", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody QlShop qlShop)
    {
        qlShop.setUpdateBy(getUsername());
        return toAjax(qlShopService.updateQlShop(qlShop));
    }

    /**
     * 删除去来店铺
     */
    @PreAuthorize("@ss.hasPermi('ql:shop:remove')")
    @Log(title = "去来店铺", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(qlShopService.deleteQlShopByIds(ids));
    }
}
